﻿<%@ Page Language="C#" MasterPageFile="~/SimplePMTModal.Master" AutoEventWireup="true" CodeBehind="ReleaseManager.aspx.cs" Inherits="SimplePMT.ReleaseManager" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
    <%= viewRendered %>
<script>
    var rid = 0;
    var tcid = 0;
    function GetContainerRelease(id) {
        if (id > 0) {
            tcid = id;
            SimplePMT.ReleaseManager.BuildReleaseList(id, function(response) {
                if (response.error != null) {
                    alert(response.error.Message);
                } else {
                    document.getElementById('releaseSelect').style.display = 'inline';
                    document.getElementById('releaseSelectList').innerHTML = response.value;
                }
            });
        } else {
            document.getElementById('releaseSelect').style.display = 'none';
        }
    }
    
    function GetReleaseOption(id) {
        rid = id;
        if (id > 0) {
            SimplePMT.ReleaseManager.GetBuildObject(id, function(response) {
                if (response.error != null) {
                    alert(response.error.Message);
                } else {
                    document.getElementById('editReleaseForm').style.display = 'inline';
                    document.getElementById('newReleaseForm').style.display = 'none';
                    var df = document.releaseForm;
                    
                    df.EditMajor.value = response.value[0];
                    df.EditMinor.value = response.value[1];
                    df.EditBuild.value = response.value[2];
                    df.EditRevision.value = response.value[3];
                    df.EditReleaseCutoffDate.value = response.value[4];
                    df.EditNotes.value = response.value[5];
                    df.EditDateReleased.value = response.value[6];

                }
            });
        } else if (id < 0) {
            document.getElementById('editReleaseForm').style.display = 'none';
            document.getElementById('newReleaseForm').style.display = 'inline';
        }
    }

    function saveRelease() {
        var df = document.releaseForm;
        SimplePMT.ReleaseManager.SaveRelease(tcid, rid, df.EditMajor.value, df.EditMinor.value, df.EditBuild.value, df.EditRevision.value, df.EditReleaseCutoffDate.value, df.EditNotes.value, df.EditDateReleased.value, function(response) {
            if (response.error != null) {
                alert(response.error.Message);
            } else {
                alert('Release updated successfully.');
                location.reload();
            }
        });
    }

    function createRelease() {
        var df = document.releaseForm;
        SimplePMT.ReleaseManager.CreateRelease(tcid, df.Major.value, df.Minor.value, df.Build.value, df.ReleaseCutoffDate.value, df.Notes.value, function(response) {
            if (response.error != null) {
                alert(response.error.Message);
            } else {
                alert('Release created successfully.');
                location.reload();
            }
        });
    }
</script>
</asp:Content>